home *** CD-ROM | disk | FTP | other *** search
- #if !defined(FWFILESP_H) && !defined(__ODFRC__)
- #define FWFILESP_H
- //========================================================================================
- //
- // File: FWFileSp.h
- // Release Version: $ 1.0d11 $
- //
- // Copyright: 1995 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWEXCDEF_H
- #include "FWExcDef.h"
- #endif
-
- #ifndef FWSTRS_H
- #include "FWStrs.h"
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__FILES__)
- #include <Files.h>
- #endif
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export on
- #endif
-
- //========================================================================================
- // Forward class declarations
- //========================================================================================
- class FW_CLASS_ATTR FW_CDirectorySpecification;
-
-
- //========================================================================================
- // FW_CFileSpecification
- //
- // This class is used to identify a disk-based file.
- //========================================================================================
-
- class FW_CLASS_ATTR FW_CFileSpecification FW_AUTO_DESTRUCT_OBJECT
- {
- public:
- FW_CFileSpecification(const FW_CDirectorySpecification& directory,
- const FW_CString& fileName);
- // Create a file specification from a directory and a file name. The file name
- // should include any extensions that might be necessary.
-
- FW_CFileSpecification(const FW_CString& fileName);
- // Create a file specification from a full or partial pathname. In the case of
- // a partial pathname, the specification will use the current default
- // directory to build a full pathname.
-
- FW_CFileSpecification(const FW_CFileSpecification& specification);
- // Copy Constructor
-
- ~ FW_CFileSpecification();
-
-
- void GetName(FW_CString& fileName) const;
- // Get the name of the file.
-
- FW_CDirectorySpecification GetParentDirectory() const;
- // Returns the path information for this file.
-
- void GetFullPath(FW_CString& fullPathName) const;
- // Returns the fully qualified path and file name for this file. The user should
- // pass in a dynamic string so as to guarantee that the path will fit inside
- // it.
-
-
- //===========================================================
- // Operators
- //===========================================================
-
- FW_Boolean operator==(const FW_CFileSpecification& theOtherFile) const;
- // Does this file represent the same file as theOtherFile.
-
- FW_Boolean operator!=(const FW_CFileSpecification& theOtherFile) const;
- // Does this file not represent the same file as theOtherFile
-
-
- FW_CFileSpecification& operator=(const FW_CFileSpecification& theOtherFile);
- // Copy all of the file information from theOtherFile so that this file spec
- // represents the same file.
-
- FW_CFileSpecification& operator=(const FW_CString& fileName);
- // Change the name of this file to fileName. fileName may be a partial pathName.
- // This does not change any of the existing path information.
-
-
- private:
- void ThrowError(short theError) const;
- // Throw the exception based on the error code.
-
- void FailOnError(short theError) const;
- // Used to check error conditions from this class.
-
- #ifdef FW_BUILD_WIN
- public:
- FW_Char WinGetDrive() const;
- // Get the letter of the drive this file is on and return it as a lower-case
- // character.
-
- void WinGetExtension(FW_CString& extension) const;
- // Get the file name extension for the Windows file.
-
- void WinSetExtension(const FW_CString& extension);
- // Set the file name extension for the Windows file.
-
- private:
- FW_CDynamicString fFileInfo;
-
- #endif
-
- #ifdef FW_BUILD_MAC
- public:
- FW_CFileSpecification(const FSSpec& specification);
- // Create a file specification based on a Macintosh FSSpec.
-
- FW_CFileSpecification& operator=(const FSSpec& macSpec);
- // This specifier will now represent the file described by macSpec.
-
- void MacGetFSSpec(FSSpec& macSpec) const;
- // Return a Macintosh FSSpec that points to this file.
-
- void MacSetTypeAndCreator(OSType aFileType, OSType aCreatorType);
- void MacGetTypeAndCreator(OSType &aFileType, OSType &aCreatorType) const;
- // Accesors to the type and creator of the file specification.
-
- private:
- FSSpec fFileInfo;
- OSType fFileType;
- OSType fCreatorType;
- #endif
-
- };
-
-
- //----------------------------------------------------------------------------------------
- // FW_CFileSpecification::operator!=
- //----------------------------------------------------------------------------------------
-
- inline FW_Boolean FW_CFileSpecification::operator!=(const FW_CFileSpecification& theOtherFile) const
- {
- return (!(FW_CFileSpecification::operator==(theOtherFile)));
- }
-
-
-
- //========================================================================================
- // FW_CDirectorySpecification
- //
- // This class is used to indentify a disk-based directory. A directory uses most of the
- // same information as a file specification, but is not a file.
- //========================================================================================
- class FW_CLASS_ATTR FW_CDirectorySpecification FW_AUTO_DESTRUCT_OBJECT
- {
- public:
- friend FW_CFileSpecification;
-
- FW_CDirectorySpecification();
- // Specifies the current default directory
-
- FW_CDirectorySpecification(const FW_CDirectorySpecification& specification);
- // Copy constructor
-
- FW_CDirectorySpecification(const FW_CString& directoryName);
- // Specifies the path by string. directoryName can be either a full or
- // partial path name.
-
- ~ FW_CDirectorySpecification();
-
-
- void GetName(FW_CString& directoryName) const;
- // Returns the name of the directory.
-
- FW_CDirectorySpecification GetParentDirectory() const;
- // Returns the parent directory of this directory.
-
- void GetFullPath(FW_CString& fullPath) const;
- // Returns the fully qualified path and name for this directory. The user should
- // pass in a dynamic string so as to guarantee that the path will fit inside
- // it.
-
-
- //===========================================================
- // Operators
- //===========================================================
-
- FW_Boolean operator==(const FW_CDirectorySpecification& theOtherDir) const;
- // Equality operator.
-
- FW_Boolean operator!=(const FW_CDirectorySpecification& theOtherDir) const;
- // Ineqaulity operator.
-
- FW_CDirectorySpecification& operator=(const FW_CDirectorySpecification& theOtherDir);
- // Assignment operator
-
- FW_CDirectorySpecification& operator=(const FW_CString& directoryName);
- // Change the directory name to directoryName. directoryName may be a partial
- // path name.
-
- FW_CDirectorySpecification& operator+=(const FW_CString& directoryName);
- // Add directoryName to the end of this path. This routine will add a path
- // separator so that the user does not need to. The remaining path information
- // may specify a subdirectory or parent directory, but must start from this
- // directory.
-
- #ifdef FW_BUILD_WIN
- public:
- FW_Char WinGetDrive() const;
- // Get the letter of the drive this file is on and return it as a lower-case
- // character.
-
- #endif
-
-
- #ifdef FW_BUILD_MAC
- public:
- FW_CDirectorySpecification(const FSSpec& macSpec);
- // Create a directory spec from a Macintosh FSSpec.
-
- FW_CDirectorySpecification& operator=(const FSSpec& macSpec);
- // Assignment operator for a Macintosh spec.
-
- void MacGetFSSpec(FSSpec& specification) const;
- // Fill in specification with the information about this directory.
-
- #endif
-
- private:
- FW_CFileSpecification fFileSpec;
-
- };
-
-
- //----------------------------------------------------------------------------------------
- // FW_CDirectorySpecification::operator!=
- //----------------------------------------------------------------------------------------
- inline FW_Boolean FW_CDirectorySpecification::operator!=(const FW_CDirectorySpecification& theOtherDir) const
- {
- return (fFileSpec != theOtherDir.fFileSpec);
- }
-
- #if FW_LIB_EXPORT_PRAGMAS
- #pragma lib_export off
- #endif
-
- #endif
-
-
-